<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>题库管理页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <link rel="stylesheet" href="/css/index.css">
    <style>

        .audio{
            margin: 90px auto;
            width: 186px;
            height: 186px;
            background:url(/images/laba.jpg) no-repeat center bottom;
            background-size:cover;
        }

    </style>
</head>
<body>
<div id="searchParam" shiro:hasPermission="sys:subject:list">
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="text" id="param" name="param" class="layui-input" autocomplete="off" placeholder="ID或词头">
        </div>
        <div class="layui-input-inline layui-form">
            <select id="papertagList"  name="papertagList" class="select">

            </select>
        </div>
        <div class="layui-input-inline layui-form" >
            <select id="languageList"  name="languageList" class="select">

            </select>
        </div>

        <div class="layui-input-inline layui-form">
            <select id="convType"  name="convType" class="select">
                <option value="1">汉外 </option>
                <option value="2">外汉</option>

            </select>
        </div>

        <div class="layui-input-inline ">
            <button class="layui-btn" id="search">
                <span class="layui-icon layui-icon-search"></span>查询
            </button>
        </div>
    </div>
</div>
<table class="layui-hide" id="subjectObject_table" lay-filter="subjectObject_table" lay-skin="line"></table>
<div id="laypage" class="$('.layui-laypage-btn').click();"></div>
<!--增加修改模块--->
<div id="edit-user-info" style="display:none;">
    <form class="layui-form" action="" style="margin-top: 10px;margin-left: 10px;margin-right: 10px;" lay-filter="languageEditFilter" id="languageEditFilter" autocomplete="off">
        <div class="layui-card-body">
            <div class="main-div">
                <input name="id" hidden/>
                <input name="deptId" hidden/>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">题目类型</label>
                        <div class="layui-input-block">
                            <select id="type" lay-filter="demo" name="type" onchange="selects()" ></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">题目语种</div>
                        <div class="layui-input-block">
                            <select id="language" name="language"></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">语种类型</div>
                        <div class="layui-input-block">
                            <select  id="statusv" name="statusv">
                                <option  value="">请选择语种类型</option>
                                <option   value="1">汉外</option>
                                <option   value="2">外汉</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-form-label">等级</div>
                        <div class="layui-input-block">
                          <select id="hskvs" name="hsk"></select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <div class="layui-form-label">填写词头</div>
                        <div class="layui-input-block">
                            <input type="text" name="entryName" placeholder="请填写词头" style="width: 800px;height: 40px;" class="layui-input">
                        </div>
                    </div><br/><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">填写题干</div>
                        <div class="layui-input-block">
                            <input type="textarea" name="stem" placeholder="请填写题干" style="width: 800px;height: 80px;" class="layui-input">
                        </div>
                    </div><br/>

                </div><br/>
                <div class="layui-form-item" id="rightSelects">
                    <div class="layui-inline">
                        <div class="layui-form-label">选项A</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseA" id="chooseA" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项B</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseB" id="chooseB" placeholder="请填写" class="layui-input">
                        </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项C</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseC" id="chooseC" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项D</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseD" id="chooseD" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline" id="rightChooses">
                        <div class="layui-form-label">正确答案&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="layui-input-block">
                            <input type="radio" name="rightKey" value="1" title="A" checked="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="2" title="B">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="3" title="C">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="4" title="D">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightEntry">
                        <div class="layui-form-label">正确答案</div>
                        <div class="layui-input-block">
                            <input type="text" name="rightEntrys" id="rightEntrys"  style="width: 800px;height: 40px;" class="layui-input" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightorRong">
                        <div class="layui-form-label">正确答案&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="layui-input-block">
                            <input type="radio" name="rightorRongs" value="1" title="对">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightorRongs" value="2" title="错">&nbsp;&nbsp;&nbsp;

                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightpaixu">
                        <div class="layui-form-label">正确答案&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="layui-input-block">
                            <input type="text" name="rightpaixus" id="rightpaixus"  style="width: 800px;height: 40px;" class="layui-input" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-form-label">图片</div>
                        <input type="text" name="imageLists" id="imageLists" value="" class="layui-input">
                        <div id="subjectimg" name="subjectimg" >
                        </div>
                        <!--   <p id="demoText" style="margin-left: 33px;"></p>-->
                    </div>
                    <div class="layui-inline">
                            <button type="button"  class="layui-btn" id="userPhoto"><i class="layui-icon"></i>上传</button>
                    </div><br/><br/>

                    <div class="layui-inline">
                        <div class="layui-form-label">音频</div>
                            <input type="text" name="recordingList" id="recordingList" value="" class="layui-input">
                        <div id="subjectrecord" name="subjectrecord" >
                        </div>

                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="recordUpload">上传</button>
                    </div><br/><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">视频</div>
                            <input type="text" name="videoLists"  id="videoLists" class="layui-input">
                        <div id="subjectvideo" name="subjectvideo" >
                        </div>


                    </div>
                    <div class="layui-inline">
                        <button type="button"  class="layui-btn" id="videoUpload">上传</button>
                    </div>


                </div>

            </div>
        </div>
        <div class="layui-form-item">
            <div style="text-align: center;">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="edit-language-submit">保存</button>
                <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
            </div>
        </div>
    </form>
</div>



<!--题目详情模块--->
<div id="show-user-info" style="display:none;margin: auto;Text-align:center;" >
    <form class="layui-form" action="" style="margin-top: 10px;margin-left: 10px;margin-right: 10px;"  autocomplete="off">
        <div class="layui-card-body">
            <div class="main-div">
                <input name="id" hidden/>
                <input name="deptId" hidden/>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div style="min-height: 30px;">
                            词头：<span id="entryNames"></span>
                        </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div style="min-height: 30px;">
                            题干：<span id="stems"></span>
                        </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div style="min-height: 30px;">
                            题目类型：<span id="stemType"></span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" id="rightSelectssa">
                    <div class="layui-inline">
                        <div class="layui-form-label">选项A</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseA" id="chooseA" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项B</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseB" id="chooseB" placeholder="请填写" class="layui-input">
                        </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项C</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseC" id="chooseC" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-form-label">选项D</div>
                        <div class="layui-input-block">
                            <input type="text" name="chooseD" id="chooseD" placeholder="请填写" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline" id="rightChoosessa">
                        <div >
                            正确答案  <input type="radio" name="rightKey" value="1" title="A" checked="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="2" title="B">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="3" title="C">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightKey" value="4" title="D">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightEntrysa">
                          <div style="min-height: 30px;">正确答案:
                                <span id="rightEntrysss"></span>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightorRongsa">
                        <div class="layui-form-label">正确答案&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="layui-input-block">
                            <input type="radio" name="rightorRongsva" value="1" title="对">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="rightorRongsva" value="2" title="错">&nbsp;&nbsp;&nbsp;

                        </div>
                    </div>
                </div>

                <div class="layui-form-item">

                    <div class="layui-inline" id="rightpaixusa">
                        <div class="layui-form-label">正确答案&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="layui-input-block">
                            <input type="text" name="rightpaixus" id="rightpaixus"  style="width: 800px;height: 40px;" class="layui-input" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-form-label">图片</div>
                        <div id="subjectimgvb" name="subjectimgvb" >  </div>
                        <!--   <p id="demoText" style="margin-left: 33px;"></p>-->
                    </div>
                  <br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">音频</div>
                        <div id="subjectrecordvb" name="subjectrecordvb" > </div>
                    </div><br/>
                    <div class="layui-inline">
                        <div class="layui-form-label">视频</div>
                        <div id="subjectvideovb" name="subjectvideovb" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
</body>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="addNewStudy" shiro:hasPermission="sys:subject:add">
            <i class="layui-icon">&#xe608;</i> 新增
        </button>
    </div>

    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="buffDelete" shiro:hasPermission="sys:subject:deleted">
            <i class="layui-icon">&#xe640;</i> 批量删除
        </button>
    </div>
    </script>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-xs" lay-event="show" shiro:hasPermission="sys:subject:show"><i class="layui-icon">&#xe621;</i>查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="sys:subject:update"> <i class="layui-icon">&#xe642;</i>编辑</a>

</script>
<script type="text/javascript" src="/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript"  src="/layui/layui.all.js"></script>
<script type="text/javascript" src="/js/core.util.js"></script>
<!---上传-->
<script type="text/javascript" src="/js/upload.js"></script>
<script type="text/javascript" src="/js/indexs.js"></script>
<!---回显数据-->
<script type="text/javascript" src="/js/selects.js"></script>
<script>
    let $ = jQuery = layui.jquery;
    let table = layui.table
        , laypage = layui.laypage
        , form = layui.form
        , layer = layui.layer
        , laydate = layui.laydate
        , tree = layui.tree;
    layui.use(['table', 'laypage', 'layer', 'laydate', 'tree'], function () {

        //搜索条件
        let searchParam = {
            param :null,
       type:null,
        language:null,
       convType :null,
        page : 1,
        pageSize:10
        };

        layui.use(['layer', 'jquery', 'form'], function () {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;

            form.on('select(demo)', function(data){
                // $("#rightpaixu .layui-input-block .layui-input").remove();

                if(data.value == 1){

                    $("#rightpaixu").addClass("layui-hide");
                    $('#rightSelects').addClass('layui-hide');
                    $('#rightChooses').addClass('layui-hide');
                    $('#rightorRong').addClass('layui-hide');
                    $("#rightEntry").removeClass('layui-hide');

                }else if(data.value == 2){//选择
                    $('#rightSelects').removeClass('layui-hide');
                    $('#rightChooses').removeClass('layui-hide');
                    $("#rightpaixu" ).addClass("layui-hide");
                    $('#rightEntry').addClass('layui-hide');
                    $('#rightorRong').addClass('layui-hide');
                    alert(data.rightKey)
                    $("#rightKey").val(data.rightKey);


                }else if(data.value == 3){
                    $('#rightSelects').removeClass('layui-hide');
                    $('#rightChooses').removeClass('layui-hide');
                    $('#rightEntry').addClass('layui-hide');
                    $('#rightorRong').addClass('layui-hide');
                    $('#rightpaixu').addClass('layui-hide');

                }else  if(data.value==4){//排序
                    $('#rightEntry').removeClass('layui-hide');

                    $('#rightSelects').addClass('layui-hide');
                    $('#rightpaixu').addClass('layui-hide');
                    $('#rightChooses').addClass('layui-hide');
                    $('#rightorRong').addClass('layui-hide');
                }else  if(data.value==5){//完形填空
                    $('#rightSelects').addClass('layui-hide');
                    $('#rightChooses').addClass('layui-hide');
                    $('#rightEntry').addClass('layui-hide');
                    $('#rightorRong').addClass('layui-hide');
                    $('#rightpaixu').addClass('layui-hide');
                }else  if(data.value==6){//对错
                    // $('#rightSelect').addClass('layui-hide');
                    $('#rightorRong').removeClass('layui-hide');
                    $('#rightSelects').addClass('layui-hide');
                    $('#rightChooses').addClass('layui-hide');
                    $('#rightEntry').addClass('layui-hide');
                    $('#rightpaixu').addClass('layui-hide');
                }
            });
        });
        //查询按钮点击事件
        $("#search").click(function () {
            alert($("#convType").val())
            searchParam.param = $("#param").val();
            searchParam.type = $("#papertagList").val();
            searchParam.language = $("#languageList").val();
            searchParam.convType = $("#convType").val();//汉外，外汉
            searchParam.page = 1;
            searchParam.pageSize = 10;
            CoreUtil.sendAjax("/dSubject/selectSubjectIsPage", searchParam, function (res) {
                laypageTable(res.data.totalRows, searchParam.page);
                if (res.data.records != null) {
                    loadTable(res.data.records);
                }
            }, "GET", false, function (res) {
                layer.msg(res.msg);
                let noAuthorityData = [];
                loadTable(noAuthorityData);
            });
        });


        $(document).ready(function(){
            CoreUtil.sendAjax("/dSubjectType/selectSubjectTypeIsNotPage", null, function (res) {

                console.log(res);
                $("#papertagList").append(new Option("试题标签", ""));
                $("#type").append(new Option("试题标签", ""));
                $.each(res.data, function (index, item) {
                    $('#papertagList').append(new Option(item.typeName, item.id));// 下拉菜单里添加元素
                    $('#type').append(new Option(item.typeName, item.id));// 下拉菜单里添加元素

                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });

//学习等级下拉选择框
            CoreUtil.sendAjax("/dStudyLevel/selectStudyLevelIsNotPage", null, function (res) {
                console.log(res);
                $("#hskvs").append(new Option("请选择学习等级", ""));
                $.each(res.data, function (index, item) {
                    $('#hskvs').append(new Option(item.levelName, item.id));// 下拉菜单里添加元素

                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });

//语种的下拉选择框languageList

            CoreUtil.sendAjax("/dLanguage/selectLanguageIsNotPage", null, function (res) {
                console.log(res);
                $("#languageList").append(new Option("语种", ""));
                $("#language").append(new Option("语种", ""));
                $.each(res.data, function (index, item) {
                    $('#languageList').append(new Option(item.languageName, item.id));// 下拉菜单里添加元素
                    $('#language').append(new Option(item.languageName, item.id));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
            });





            //分页获取列表信息接口
            CoreUtil.sendAjax("/dSubject/selectSubjectIsPage",  searchParam, function(res) {
                console.log(res);
                laypageTable(res.data.total, searchParam.page);
                if (res.data.records != null) {
                    loadTable(res.data.records);
                }
            }, "GET", false, function (res) {
                layer.msg("抱歉！您暂无获取列表的权限");
                let noAuthorityData = [];
                loadTable(noAuthorityData);
            });
        });

        //分页条
        let laypageTable = function (count, currentPage) {
            laypage.render({
                elem: 'laypage'
                , count: count
                , limit: searchParam.pageSize
                , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                , curr: location.hash.replace('#!currentPage=', '') //获取起始页
                , hash: 'currentPage' //自定义hash值
                , limits: [10, 25, 50, 100, 300, 500, 2000]
                , jump: function (obj, first) {
                    if (!first) {
                        searchParam.page = obj.curr;
                        searchParam.pageSize = obj.limit;
                        CoreUtil.sendAjax("/dSubject/selectSubjectIsPage", searchParam, function (res) {
                            if (res.data.records != null) {
                                loadTable(res.data.records);
                                laypageTable(res.data.total, searchParam.page);
                            }
                        }, "GET", false, function (res) {
                            layer.msg("抱歉！您暂无获取列表信息的权限");
                            let noAuthorityData = [];
                            loadTable(noAuthorityData);
                        });

                    }
                }
            });
        };

        //渲染table
        let loadTable = function (data) {
            table.render({
                elem: '#subjectObject_table'
                , cols: [
                    [ {type: 'checkbox', fixed: 'left'},
                        {type: 'id', fixed: 'left', title: '试题ID', width: '10%', type: 'numbers'},
                        {field: 'typeName', title: '试题标签', width: '15%', event: 'typeName', style:'cursor: pointer;' },
                        {field: 'languageName', title: '语种名称', width: '15%', event: 'languageName', style:'cursor: pointer;' },
                        {field: 'languageType', title: '词条类型', width: '15%', event: 'languageType', style:'cursor: pointer;',templet:function(item){
                            if(item.languageType==1){
                                return "汉外"
                            }   if(item.languageType==2){
                                    return "外汉"
                                }

                            }},
                        {field: 'entryName', title: '词头', width: '15%', event: 'entryName', style:'cursor: pointer;'},
                        {field: 'stem', title: '题干', width: '15%', event: 'stem', style:'cursor: pointer;'},
                        {width: '12%', toolbar: "#tool", title: '操作'}
                    ]
                ]
                , data: data
                , loading: true
                , even: true
                , limit: data.length
                , toolbar: '#toolbar'
            });
        };
        //监听表格头部工具栏事件
        table.on('toolbar(subjectObject_table)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case 'addNewStudy':
                    //重置表单数据
                    $("#languageEditFilter")[0].reset();
                    form.render();
                    //打开弹框
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: false, //是否允许拉伸
                        maxmin: false, //最大最小化
                        title: "新增信息",
                        area: ['100%', '100%'],
                        content: $("#edit-user-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //初始化部门树型
                    break;
                case 'batchDeleted':
                    let checkStatus = table.checkStatus(obj.config.id);
                    let data2 = checkStatus.data;
                    if (data2.length == 0) {
                        layer.msg("请选择要删除的用户");
                    } else {
                        let userIds = [];
                        $(data2).each(function (index, item) {
                            userIds.push(item.id);
                        });
                        tipDialog(userIds, "");
                    }
                    break;
                case 'buffDelete':
                    let checkStatuss = table.checkStatus(obj.config.id);
                    let data2s = checkStatuss.data;
                    if (data2s.length == 0) {
                        layer.msg("请选择要删除的用户");
                    } else {
                        let userIdss = [];
                        $(data2s).each(function (index, item) {
                            userIdss.push(item.id);
                        });
                        tipforbidDialog(userIdss, "");
                    }
                    break;
                case 'LAYTABLE_TIPS':
                    layer.msg("这是工具栏右侧自定义的一个图标按钮");
                    break;
            }
        });
        //监听行工具事件
        table.on('tool(subjectObject_table)', function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case 'batdel':
                    let userIds = [];
                    userIds.push(data.id);
                        sureDelete(userIds);//删除


                    break;
                case 'edit':
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: true, //是否允许拉伸
                        maxmin: true, //最大最小化
                        title: "修改信息",
                        area: ['100%', '100%'],
                        content: $("#edit-user-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //回显数据，填充表格
                    setFormValue(obj);
                    //初始化部门树型
                    initTree("");
                    break;
                case 'show':
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        resize: true, //是否允许拉伸
                        maxmin: true, //最大最小化
                        title: "查看题目",
                        area: ['40%', '90%'],
                        content: $("#show-user-info") //引用的弹出层的页面层的方式加载修改界面表单
                    });
                    //回显数据，填充表格
                    setFormValues(obj);
                    //初始化部门树型
                    initTree("");
                    break;
            }
        });

        //是否批量删除确认框
        let tipforbidDialog = function (userIds, username) {
            layer.open({
                content: '确定要删除吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/dSubject/deleteSubject", JSON.stringify(userIds), function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg(res.msg);
                    });
                }
            });
        };

        //显示建议的详细信息
        let suggestiondetail = function(id){

            CoreUtil.sendAjax("/dLanguage/selectLanguageIsPage/" + id,null,function(res) {

                 $("#username").html(res.data.username);
                 $("#phone").html(res.data.phone);
                 $("#email").html(res.data.email);
                 $("#update_time").html(res.data.updateTime);
                 $("#contents").html(res.data.content);

            }, "POST", false, function (res) {
                console.log(res);
                layer.msg(res.msg);
            });
            layer.open({
                //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                type: 1,
                resize: false, //是否允许拉伸
                maxmin: false, //最大最小化
                title: "建议详情",
                area: ['40%', '60%'],//宽，高
                shadeClose: true, //点击弹层外区域关闭
                content: $("#userInfoDetailDiv")
            });
        };

        //监听提交-编辑/新增用户信息弹框
        form.on('submit(edit-language-submit)', function (data) {
            var ids=data.field.type;
            if(ids==1){//填空
                data.field.rightKey=data.field.rightEntrys
            }else if(ids==2){//选择
                var chooseList = [];
                // // chooseList.push({"choose":"A"});
                // chooseList.push({"choose":"A","text":$('#chooseA').val()});
                // chooseList.push({'choose':'B','text':$('#chooseB').val()});
                // chooseList.push({'choose':'C','text':$('#chooseC').val()});
                // chooseList.push({'choose':'D','text':$("#chooseD").val()});
                chooseList= "["+"{'choose':'A','text':'"+$('#chooseA').val()+"'},{'choose':'B','text':'"+$('#chooseB').val()+"'},{'choose':'C','text':'"+$('#chooseC').val()+"'},{'choose':'D','text':'"+$('#chooseD').val()+"'}]";
                data.field.chooseLists=chooseList
                // data.field.rightKey=data.field.rightKeys;
            }else if(ids==3){//听力
                var chooseList = [];
                // chooseList.push({'choose':'A','text':$('#chooseA').val()});
                // chooseList.push({'choose':'B','text':$('#chooseB').val()});
                // chooseList.push({'choose':'C','text':$('#chooseC').val()});
                // chooseList.push({'choose':'D','text':$("#chooseD").val()});
                chooseList= "["+"{'choose':'A','text':'"+$('#chooseA').val()+"'},{'choose':'B','text':'"+$('#chooseB').val()+"'},{'choose':'C','text':'"+$('#chooseC').val()+"'},{'choose':'D','text':'"+$('#chooseD').val()+"'}]";
                data.field.chooseLists=chooseList
                // data.field.rightKey=data.field.rightKeys;
            }else if(ids==4){//排序
                data.field.rightKey=data.field.rightEntrys;

            }else if(ids==5){//完型

            }else if(ids==6){//判断
                data.field.rightKey=data.field.rightorRongs;
            }

            delete  data.field.chooseA;
            delete  data.field.chooseB;
            delete  data.field.chooseC;
            delete  data.field.chooseD;
            delete  data.field.rightEntrys;
            delete  data.field.rightorRongs;
            delete  data.field.rightpaixus;
            delete  data.field.rightKeys;

            if (data.field.id === undefined || data.field.id === null || data.field.id === "") {
                CoreUtil.sendAjax("/dSubject/addSubject", JSON.stringify(data.field), function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                    $(".layui-laypage-btn").click();
                }, "POST", false, function (res) {
                    layer.msg(res.msg);

                });
            } else {

                alert(JSON.stringify(data.field))
                // $("#videoList").val($("#videoLists").val())
                    CoreUtil.sendAjax("/dSubject/updateSubject",JSON.stringify(data.field), function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                    $(".layui-laypage-btn").click();

                }, "POST", false, function (res) {
                    layer.closeAll(); //疯狂模式，关闭所有层
                    layer.msg(res.msg);
                });
            }
            return false;

        });
        //是否删除确认框
        let sureDelete = function (pkId) {
            layer.open({
                content: '确定要删除该记录吗?',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    $.ajax({
                        type: "DELETE",
                        url: "/dLanguage/deleteLanguage?id="+pkId,
                        dataType: "json",
                        success: function(res){
                            layer.msg(res.message);
                            $(".layui-laypage-btn").click();
                        }, error: function (){
                            layer.msg(res.message);
                        }
                    });


                }
            });
        };
    });
</script>